package anonymous.classes;

/**
 * @author shkstart
 * @date 2022/5/21 - 22:21
 */

// 匿名类的例题：
public class PersonTest1 {
    public static void main(String[] args) {

//        匿名子了非匿名对象
        Person person = new Person() {
            @Override
            public void eat() {
                System.out.println("好好吃饭哦");
            }
        };

        method1(person);

        System.out.println("*****************************");

        method1(new Person() {
            @Override
            public void eat() {
                System.out.println("吃大口吃！");
            }
            public void walk() {
                System.out.println("走路健康");
            }
        });

    }


    public static void method1(Person p) {
        p.eat();
        p.walk();

    }

}




abstract class Person {
    String name;
    int age;

    public Person() {

    }
    public Person(String name,int age) {
        this.name = name;
        this.age = age;
    }

//    public void eat() {
//        System.out.println("人吃饭");
//    }

    abstract public void eat();

    public void walk() {
        System.out.println("人走路");

    }

}



